package com.moli.controller;

import com.moli.domain.ResponseResult;
import com.moli.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author： xiaolu
 * @Date： 2023-06-07 22:24
 * @Description： 文章控制层
 */

@RestController
@RequestMapping("/article")
public class ArticleController {

	@Autowired
	private ArticleService articleService;

	/**
	 * 热门文章列表查询接口
	 * @return
	 */
	@GetMapping("/hotArticleList")
	public ResponseResult hotArticleList(){

		ResponseResult result =  articleService.hotArticleList();
		return result;
	}

	/**
	 * 分页查询文章列表
	 * @param pageNum
	 * @param pageSize
	 * @param categoryId
	 * @return
	 */
	@GetMapping("/articleList")
	public ResponseResult articleList(Integer pageNum,Integer pageSize,Long categoryId){
		return articleService.articleList(pageNum,pageSize,categoryId);
	}

	/**
	 * 文章详情
	 * @param id
	 * @return
	 */
	@GetMapping("/{id}")
	public ResponseResult getArticleDetail(@PathVariable("id") Long id){
		return articleService.getArticleDetail(id);
	}

	@PutMapping("/updateViewCount/{id}")
	public ResponseResult updateViewCount(@PathVariable("id") Long id){
		return articleService.updateViewCount(id);
	}
}
